<?php
/**
 * Created by PhpStorm.
 * User: fengliu
 * Date: 15/8/3
 * Time: 上午10:29
 */

namespace Api\Controller;


use Think\Controller;

class ReportController extends Controller
{
    public function getReport(){
        $uid=I('post.user_id');
        $did=I('post.doctor_id');
        $cUid=is_login();
        if(in_array($cUid,array($cUid,$did))){
            $data=M('UserReport')->where(array('doctor_id'=>$did,'user_id'=>$uid))->select();
//            var_dump($data,M('UserReport')->getLastSql());exit;
        }
        else{
            $this->error('数据不匹配');
        }
        if(empty($data)){
            $this->error('暂无数据');
        }else{
            $this->ajaxReturn(array('data'=>$data,'info'=>'操作成功','status'=>1));
        }
    }

    public function getReportById(){
        $uid=is_login();
        $id=I('post.id',0,'intval');
        if(empty($id)){
            $this->error('缺少报告id');
        }else{
            $data=M('UserReport')->where(array('doctor_id|user_id'=>$uid,'id'=>$id))->find();
        }
        if(empty($data)){
            $this->error('该数据不存在!');
        }else{
            $this->ajaxReturn(array('data'=>$data,'info'=>'操作成功','status'=>1));
        }
    }
}